import 'package:flutter/material.dart';
import 'package:fluro/fluro.dart';

import '../pages/index_page.dart';
import '../pages/unknown/unknown_page.dart';
import '../pages/product/product_search.dart';
import '../pages/product/product_list.dart';
import '../pages/product/product_detail.dart';
import '../pages/comment/product_comment.dart';
import '../pages/mine/register.dart';
import '../pages/mine/profile.dart';
import '../pages/mine/change_password.dart';
import '../pages/mine/login.dart';
import '../pages/mine/favorite.dart';
import '../pages/mine/score.dart';
import '../pages/mine/coupon.dart';
import '../pages/mine/address.dart';
import '../pages/mine/address_add.dart';
import '../pages/order/order_confirm.dart';
import '../pages/order/order_pay.dart';
import '../pages/order/order_detail.dart';
import '../pages/order/order_list.dart';
import '../pages/order/order_comment.dart';
import '../pages/splash/splash.dart';

// 默认页
var indexHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
  return index_page();
});

// 未知页
var unknownHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
  return const UnknownPage();
});

// 商品搜索页面
var productSearchHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
  return const ProductSearch();
});

// 商品列表页面
var productListHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
  return ProductList(
      sid: params['sid']!.first, cate_name: params['cate_name']!.first);
});

// 商品详情页面
var productDetailHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
  return ProductDetail(id: params['id']!.first);
});

// 商品评论列表页面
var productCommentHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
  return ProductComment(id: params['id']!.first);
});

// 注册页面 - 快速登陆
var registerHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
  return const Register();
});

// 用户中心
var mineHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
  // return Mine();
  return index_page();
});

// 分类页面
var categoryHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
  // return Mine();
  return index_page();
});

// 分类页面
var cartHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
  // return Mine();
  return index_page();
});

// 编辑用户页面
var profileHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
  return Profile();
});

// 修改密码页面
var changePasswordHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
  return const ChangePassword();
});

// 登录页面
var loginHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
  return const Login();
});

// 收藏列表页面
var favoriteHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
  return const Favorite();
});

// 积分列表页面
var scoreHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
  return const Score();
});

// 优惠券列表页面
var couponHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
  return const Coupon();
});

// 收货地址列表页面
var addressHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
  return const Address();
});

// 添加收货地址页面
var addressAddHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
  return AddressAdd();
});

// 订单确认页面
var orderConfirmHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
  return OrderConfirm(
      cartId: params['cartId']!.first,
      isNew: int.parse(params['isNew']!.first));
});

// 订单完成
var orderPayHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
  return OrderPay(uni: params['uni']!.first);
});

// 订单详情
var orderDetailHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
  return OrderDetail(uni: params['uni']!.first);
});

// 订单详情
var orderListHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
  return OrderList(type: int.parse(params['type']!.first));
});

// 评论商品
var orderCommentHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
  return const OrderComment();
});

// 欢迎页面
var splashHandler = Handler(
    handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
  return const Splash();
});
